/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include <QtCore/QTimer>
#include <QtCore/QTime>
#include <QtGui/QPainter>
#include <QtGui/QColorDialog>

#include "ColorPicker.h"

namespace PQBuilder
{
	ColorPicker::ColorPicker(QWidget *parent)
	{
		 _color=QColor(255,0,0);
		 this->setMaximumSize(QSize(64,28));
	}

	void ColorPicker::paintEvent(QPaintEvent *evt)
	{
		QPainter painter(this);
		painter.setRenderHint(QPainter::Antialiasing);
		painter.fillRect(this->rect(),_color);

		painter.setPen(QColor(0,0,0));
		
		painter.drawRect(this->rect());
	}

	void ColorPicker::mousePressEvent(QMouseEvent *evt)
	{
		QColor color=QColorDialog::getColor(_color);
		if(color.isValid()){
			setColor(color);
		}
	}

	void ColorPicker::mouseDoubleClickEvent( QMouseEvent *evt )
	{
	}

}
